package com.zysc.processflow.common.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Value("${cors.enabled:true}")
    boolean CorsEnabled;
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        if (CorsEnabled){
            registry.addMapping("/**")
                    // 设置允许跨域请求的域名
                    .allowedOriginPatterns("*")
                    .allowedMethods("*")
                    .allowedHeaders("*")
                    .exposedHeaders("token")
                    .allowCredentials(true);
        }
    }
}


